
$(document).ready(function() {	
	$("#gaoliang28").removeClass("sub-menu-link").addClass("selected");
	window.random_code_index = 0;
	$("#defButton").click(function() {		
		// 交易时间
		$("#tranDateTime").val(getCurentTime());
		// 国付宝服务器时间
		$("#gopayServerTime").val(getCurentTime());
		// 商户流水号
		$("#merOrderNum").val(genRandum());
		//设置商户识别码
		$("#verficationCode").val("11111aaaaa");
	});
	
	$.formValidator.initConfig({
		validatorgroup : "1",
		formid : "form",
		onerror : function(input1, input2) {
			return false;
		}
	});

	$("#bidNo").formValidator({
		onshow : " "
	}).inputValidator({
		min : 1,
		onerror : "标号不允许为空！"
	});
	
	/*$("#merId").formValidator({
		onshow : " "
	}).inputValidator({
		min : 1,
		onerror : "商户ID不允许为空！"
	});*/
	
	$("#merOrderNum").formValidator({
		onshow : " "
	}).inputValidator({
		min : 1,
		onerror : "订单号不允许为空！"
	});
	
	$("#tranDateTime").formValidator({
		onshow : " "
	}).inputValidator({
		min : 1,
		onerror : "交易时间不允许为空！"
	});
	
	
});

function getRandomNum() {
	window.random_code_base = (([ 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J',
			'K', 'M', 'N' ])[new Date().getMonth()])
			+ '_' + (Math.random() * 10000000000 + '').substring(0, 4);	
	return window.random_code_base + "_" + (window.random_code_index++);
}
/**
 * 生成时间+四位随机数
 * lixu 2016-03-23 17:10:09
 */
function genRandum(){
    var tail = Math.random()*(10000);
    tail=Math.floor(tail).toString();//向下取整转字符串
    while(tail.length<4){
        tail='0'+tail;
    }

    return getCurentTime()+tail;
}
/**
 * 获取当前时间
 * 格式为20160323165212的时间字符串
 * lixu 2016-03-23 17:10:09
 */
function getCurentTime(){ 
    var currentTime;
    var now = new Date();
   
    var year = now.getFullYear();
    var month = now.getMonth() + 1;
    var day = now.getDate();
   
    var hh = now.getHours();
    var mm = now.getMinutes();
    var ss = now.getSeconds();  

    if(month < 10) month = '0' + month;
    if(day < 10) day= '0' + day;
    if(hh < 10) hh = '0' + hh;
    if(mm < 10) mm = '0' + mm; 
    if(ss < 10) ss = '0' + ss; 

    currentTime = year+month+day+hh+mm+ss;

    return currentTime; 
} 